﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace MixScript.BLL
{
    public class cUpload : cBaseBLL
    {
        public cUpload()
        {
        }


        public void saveUploadLog(string sid, string filename,string userlogin,int filetyp)
        {
            string ss = "";
            try
            {
                //string sql = "select top 0 * from tb_upload";
                
                DataTable dt = new DataTable();
                getTableStructure(ref dt,"tb_upload");
                

                
                DataRow dr = dt.NewRow();

                dr["user_name"] = userlogin;
                dr["lst_upd_ts"] = getServerTime();
                dr["file_uploaded"] = sid;
                dr["original_file"] = filename;
                dr["filetype"] = filetyp;
                dr["status"] = 0;
                dr["upload_id"] = 1;

                dt.Rows.Add(dr);
                if (Dbserver.openConn())
                {
                    Dbserver.SqlUpdate(dt, "tb_upload", out ss);
                    Dbserver.CommitAndCloseConn();
                }
                
            }
            catch (Exception ex)
            {

                
                if (Dbserver.StateConn == ConnectionState.Open)
                {
                    Dbserver.ForceRollBackNClose();
                }
                throw new Exception(ss);
            }

        }
        
    }
}
